//
//  SCHomeViewController.m
//  ShangChengMoBan
//
//  Created by yaoqi yaoqi on 16/9/5.
//  Copyright © 2016年 ping. All rights reserved.
//

#import "SCHomeViewController.h"
#import "SDCycleScrollView.h"
#import "PingLunViewController.h"
#import "BaoZhengTableViewCell.h"
#import "GouWuCheMainViewController.h"
#import "ChanPinPeiZhiView.h"
#import "PeiZhiBtn.h"
#import "DengLuViewController.h"

@interface SCHomeViewController ()<UITableViewDataSource,UITableViewDelegate,UIWebViewDelegate,peiZhiBtnDelegate,SDCycleScrollViewDelegate>
- (IBAction)baoZheng:(id)sender;
- (IBAction)pingLun:(id)sender;

- (IBAction)xuanZe:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *jiFen;
@property (weak, nonatomic) IBOutlet UILabel *guiGeLabel;
@end

@implementation SCHomeViewController
{
    
    RWScrollViewView * _scroll;//scroll上拉刷新
    UIView *view,* view2,* _footView,* viewHome,*_viewBaoZheng;
    float  H;//文字高度
    NSString * _content;//产品特色数据源
    UILabel * _content2;//显示更多内容
    UIButton * _button;//显示更多按钮
    UIView * _xuanZeView;
    UIButton *_shangLa;//上拉
    NSMutableArray * _btnArr;//颜色数组
     NSMutableArray * _sizeArr;//尺寸数组
    float _colorBtnH;//颜色按钮最后一个高度
    float _sizeBtnH;//尺寸按钮最后一个高度
    UILabel * _num;//商品数量
    UIImageView * _imageLa;//上拉图片
    NSArray * _arr;//服务保证内容数据源
    UIWebView * _webView;//最底部webview
    NSInteger colorTag;//用于存放选中颜色的tag值(参数需要)
    NSInteger sizeTag;//存放选中尺寸的tag值
    NSDictionary * _dic;//数据源
    NSMutableArray * _shuXingArr;//属性数据源
    ChanPinPeiZhiView *_peiZhiView;
    NSArray *_choseAry;
    NSString * _gouMaiNum;
}
- (void)viewDidLoad {
    
    
    _arr = @[@{@"title":@"卖家承诺24小时发货",@"content":@""},@{@"title":@"全场包邮",@"content":@"藁城内环有商品均包邮"},@{@"title":@"30天无理由退换货",@"content":@"消费者在满足30天无理由退换货申请条件下,可以提出30天无理由退货申请,据不骗人,赶紧退过吧"},@{@"title":@"正品保证",@"content":@"该商品由平台担保为正品,'假一赔十'"}];
    [super viewDidLoad];
    _btnArr = [NSMutableArray array];
    _sizeArr = [NSMutableArray array];
    [self requestDatas];
  }
-(void)requestDatas{
      [TCUtils showLoadingWithView:self.view];
    [NetWorking NEWjieKouQingQiu:FL_detail ANDIP:IP And:@{@"goodsId":_FL_chan._id} anBlock:^(NSDictionary *dic, NSError *error) {
        [TCUtils hiddonLoadingWithView:self.view];
        if (!error) {
            if ([dic[Code] intValue] == 200) {
               NSString * a = [self dictionaryToJson:dic];
                _FL_chanPin = [FL_ChanPinModel objectFromDictionary:dic[Response]];
                 _scroll = [[RWScrollViewView alloc]initWithFrame:CGRectMake(0, 20, KScreenWidth, KScreenHeight-60)];
                _scroll.footerPullToRefreshText = @"上拉查看图片详情";
                _scroll.footerReleaseToRefreshText = @"松开查看图片详情";
                [self.view addSubview:_scroll];
                [_scroll addFooterWithTarget:self action:@selector(shangLa)];
                _scroll.backgroundColor = [UIColor colorWithHue:0.00 saturation:0.00 brightness:0.94 alpha:1.00];
                [self headerView];//头部试图
                [self teSe];//中间特色试图
                //下部试图

//                _xuanZeView = [[[NSBundle mainBundle]loadNibNamed:@"FenLei" owner:self options:nil]lastObject];
//                _xuanZeView.frame = CGRectMake(0, view2.bottom, KScreenWidth, 161);
//                [_scroll addSubview:_xuanZeView];
//                if (_FL_chanPin.giveIntegral == nil) {
//                    _jiFen.text = @"可获得0积分";
//                }else{
//                    _jiFen.text = [NSString stringWithFormat:@"可获得%@积分",_FL_chanPin.giveIntegral];
//                }
                

                [self sendViewDraw];

                //上啦
//                _shangLa = [[UIButton alloc]initWithFrame:CGRectMake(0,_xuanZeView.bottom+ 5, KScreenWidth, 20)];
//                [_shangLa setTitle:@"上拉查看图片详情" forState:UIControlStateNormal] ;
//                [_shangLa setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//                [_shangLa addTarget:self action:@selector(shangLa) forControlEvents:UIControlEventTouchUpInside];
//                _shangLa.titleLabel.font = [UIFont systemFontOfSize:12];
//                [_scroll addSubview:_shangLa];
//                _imageLa = [[UIImageView alloc]initWithFrame:CGRectMake(KScreenWidth/2-65, _xuanZeView.bottom+9, 12, 12)];
//                _imageLa.image = [UIImage imageNamed:@"上拉箭头"];
//                [_scroll addSubview:_imageLa];
                //返回按钮
                                //底部视图
                [self footView];
                _scroll.contentSize = CGSizeMake(KScreenWidth, view2.bottom+191);
                //选择颜色 尺寸属性
                [self shuXing];
                //进入服务说明
                [self baoZheng];
                [self drawBackButton];
            }
        }
    }];
}
#pragma mark 返回上一级
-(void)clickBack{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark scroll头部内容
-(void)headerView{
    view = [[UIView alloc]init];
    view.backgroundColor = [UIColor whiteColor];
    [_scroll addSubview:view];
    NSArray * image = @[_FL_chanPin.coverImage];
    SDCycleScrollView * sdcView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, KScreenWidth, 270) imageURLStringsGroup:image];
    sdcView.delegate = self;
    sdcView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    sdcView.autoScrollTimeInterval = 3;
    sdcView.dotColor = [UIColor whiteColor];
    sdcView.placeholderImage = [UIImage imageNamed:PLaceHolderImage];
    [view addSubview:sdcView];
    //商品名
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:_FL_chanPin.name];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:3];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, ((NSString *)_FL_chanPin.name).length)];
    //获取计算高度
    CGSize contentSize = [_FL_chanPin.name boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size;
    UILabel * title = [[UILabel alloc]initWithFrame:CGRectMake(8, sdcView.bottom+10, contentSize.width, contentSize.height)];
    title.textColor = MaintextColor;
    title.attributedText = attributedString;
    title.numberOfLines = 0;
    title.font = [UIFont systemFontOfSize:13];
    [view addSubview:title];
    //价格
    NSString * titName = [NSString stringWithFormat:@"¥%.2f",[_FL_chanPin.ourPrice floatValue]];
    CGSize dateSize = [titName boundingRectWithSize:CGSizeMake(KScreenWidth, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil].size;
    UILabel * prize = [[UILabel alloc]initWithFrame:CGRectMake(8, title.bottom+5,dateSize.width, 20)];
    prize.textColor =[UIColor colorWithHue:0.95 saturation:0.88 brightness:1.00 alpha:1.00];
    prize.font = [UIFont systemFontOfSize:17];
    prize.text = [NSString stringWithFormat:@"¥%.1f",[_FL_chanPin.ourPrice floatValue]] ;
    [view addSubview:prize];
    //原价

    NSMutableAttributedString *  attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"原价¥%.1f",[_FL_chanPin.originalPrice floatValue]] ];
    [attribtStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, attribtStr.length)];

    
    UILabel * zheKou = [[UILabel alloc]initWithFrame:CGRectMake(prize.right+6, title.bottom+6, 80, 20)];
    zheKou.textColor =[UIColor lightGrayColor];
    zheKou.font = [UIFont systemFontOfSize:10];
    zheKou.attributedText = attribtStr;
    [view addSubview:zheKou];
    //购买人数
    UILabel * perNum = [[UILabel alloc]initWithFrame:CGRectMake(8, prize.bottom+5, KScreenWidth/3, 15)];
    perNum.textColor =[UIColor lightGrayColor];
    perNum.font = [UIFont systemFontOfSize:10];

    perNum.text = [NSString stringWithFormat:@"%@人购买",_FL_chanPin.salesAmount];

    [view addSubview:perNum];
    //好评率
    UILabel * good = [[UILabel alloc]initWithFrame:CGRectMake(perNum.right, prize.bottom+5, KScreenWidth/3-15, 15)];
    good.textColor =[UIColor lightGrayColor];
    good.font = [UIFont systemFontOfSize:10];
    good.text = @"好评率%99.88";
    [view addSubview:good];
    //推荐指数
    UILabel * xingLab = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth-105, prize.bottom+5, 45, 15)];
    xingLab.textColor =[UIColor lightGrayColor];
    xingLab.font = [UIFont systemFontOfSize:10];
    xingLab.text = @"推荐指数:";
    [view addSubview:xingLab];
    int ping = [_FL_chanPin.rating intValue];
    for (int i=0; i<ping; i++) {
        UIImageView * xingImage = [[UIImageView alloc]initWithFrame:CGRectMake(xingLab.right+10*i, prize.bottom+6, 10, 10)];

        xingImage.image = [UIImage imageNamed:@"星"];
        [view addSubview:xingImage];
        [_scroll addSubview:view];
    }
    view .frame = CGRectMake(0, 0, KScreenWidth, good.bottom+7);

  
  

    [_scroll addSubview:view];
 }

-(void)drawBackButton{
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(10, 20, 60, 44)];
    
    [btn addTarget:self action:@selector(clickBack) forControlEvents:UIControlEventTouchDown];
    
    UIImageView * btnImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 7, 32 , 32)];
    [btnImage setImage:[UIImage imageNamed:@"返回-1"]];
    [btn addSubview:btnImage];
    
    [self.view addSubview:btn];
}

#pragma mark scroll中间保证内容
-(void)teSe{
    view2 = [[UIView alloc]init];
    view2.backgroundColor = [UIColor whiteColor];
    UIImageView * chanPin = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 15, 15)];
    chanPin.image = [UIImage imageNamed:@"特色图标"];
    [view2 addSubview:chanPin];
    UILabel * teSe = [[UILabel alloc]initWithFrame:CGRectMake(chanPin.right+2,10, 100, 20)];
    teSe.textColor =[UIColor grayColor];
    teSe.font = [UIFont systemFontOfSize:13];
    teSe.text = @"产品特色:";
    [view2 addSubview:teSe];
    //内容

//    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:_FL_chanPin.keywords];
//    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
//    [paragraphStyle setLineSpacing:5];
//    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, _FL_chanPin.keywords.length)];
//    //获取计算高度
//    CGSize contentSize = [_FL_chanPin.keywords boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size;
//    UILabel * content1 = [[UILabel alloc]initWithFrame:CGRectMake(10,teSe.bottom+5, contentSize.width, contentSize.height)];
//    content1.textColor =[UIColor grayColor];
//    content1.font = [UIFont systemFontOfSize:10];
//    content1.attributedText = attributedString;
//    content1.numberOfLines = 0;//多行
//    [view2 addSubview:content1];
//     _content2 = [[UILabel alloc]initWithFrame:CGRectMake(10,content1.bottom, contentSize.width, 0)];

    _content2 = [[UILabel alloc]initWithFrame:CGRectMake(10,teSe.bottom+5, KScreenWidth-20, 20)];

    _content2.textColor =[UIColor grayColor];
    _content2.text = _FL_chanPin.intro;
    _content2.numberOfLines = 0;//多行
    _content2.font = [UIFont systemFontOfSize:10];
    _content2.numberOfLines = 0;
    [view2 addSubview:_content2];

    //显示更多按钮
     _button = [[UIButton alloc]initWithFrame:CGRectMake(50, _content2.bottom, KScreenWidth-100, 15)];
    _button.titleLabel.font = [UIFont systemFontOfSize:11];
    [_button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [_button setTitle:@"点击显示更多" forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(xianShi:) forControlEvents:UIControlEventTouchUpInside];
    [_button setImage:[UIImage imageNamed:@"下 (1)"] forState:UIControlStateNormal];
    [_button setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -150)];
    [_button setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 20)];
     _button.selected = NO;
    [view2 addSubview:_button];
    view2.frame = CGRectMake(0, view.bottom+5, KScreenWidth, _button.bottom+8);
    [_scroll addSubview:view2];
    
}

-(void)sendViewDraw{
    _xuanZeView = [[[NSBundle mainBundle]loadNibNamed:@"FenLei" owner:self options:nil]lastObject];
    _xuanZeView.frame = CGRectMake(0, view2.bottom, KScreenWidth, 161);
    [_scroll addSubview:_xuanZeView];
    
    _jiFen.text = [NSString stringWithFormat:@"可获得%@积分",@"0"];
    
    _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, _xuanZeView.bottom + 5, KScreenWidth, 0)];
    _webView.scrollView.scrollEnabled=NO;
    _webView.delegate=self;
    
    [_scroll addSubview:_webView];

}
#pragma mark  点击查看更多
-(void)xianShi:(UIButton *)button{
    button.selected = !button.selected;

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:_FL_chanPin.intro];

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:5];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,_FL_chanPin.intro.length)];
    CGSize contentSize = [_FL_chanPin.intro boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size;
      _content2.attributedText = attributedString;
    if (button.selected) {
//<<<<<<< HEAD
//          [UIView animateWithDuration:0.4 animations:^{
//            CGSize s = _scroll.contentSize;
//            s.height += contentSize.height;
//            _scroll.contentSize = s;
//            CGRect frame1 = _content2.frame;
//            frame1.size = contentSize;
//            _content2.frame = frame1;
//            CGRect frame2 = view2.frame;
//            frame2.size.height += contentSize.height;
//            view2.frame = frame2;
//            CGRect frame3 = _button.frame;
//            frame3.origin.y = _content2.bottom+5;
//            _button.frame = frame3;
//            CGRect frame4 = _xuanZeView.frame;
//            frame4.origin.y = view2.bottom;
//            _xuanZeView.frame = frame4;
//            CGRect frame5 = _shangLa.frame;
//            frame5.origin.y = _xuanZeView.bottom+5;
//            _shangLa.frame = frame5;
//            CGRect frame6 = _imageLa.frame;
//            frame6.origin.y = _xuanZeView.bottom+9;
//            _imageLa.frame = frame6;
//              CGRect frame7 = _webView.frame;
//              frame7.origin.y = _xuanZeView.bottom+5;
//              _webView.frame = frame7;
//=======
          [UIView animateWithDuration:0.2 animations:^{
              _content2.height = contentSize.height;
              _button.yv = _content2.bottom;
              view2.height = _button.bottom+8;
              _xuanZeView.yv = view2.bottom;
              _webView.yv = _xuanZeView.bottom + 5;
              _scroll.contentSize = CGSizeMake(KScreenWidth, _webView.bottom);
              

        }];
    }else{
          [UIView animateWithDuration:0.2 animations:^{
              _content2.height = 20;
              _button.yv = _content2.bottom ;
              view2.height = _button.bottom+8;
              _xuanZeView.yv = view2.bottom;
              _webView.yv = _xuanZeView.bottom + 5;
              _scroll.contentSize = CGSizeMake(KScreenWidth, _webView.bottom);
         }];
      }
  }
#pragma mark 下部选择跳转内容
-(void)footView{
    _footView = [[UIView alloc]initWithFrame:CGRectMake(0, KScreenHeight-40, KScreenWidth, 40)];
    _footView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_footView];
    UIButton * guc = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/7*5, 0, KScreenWidth/7*2, 40)];
    guc.backgroundColor = [UIColor orangeColor];
    [guc setTitle:@"加入购物车" forState:UIControlStateNormal];
    [guc setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    guc.titleLabel.font = [UIFont systemFontOfSize:13];
    [guc addTarget:self action:@selector(guc) forControlEvents:UIControlEventTouchUpInside];
    [_footView addSubview:guc];
    UIButton * qq = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/7*2, 10, 20, 20)];
    [qq setBackgroundImage:[UIImage imageNamed:@"q"] forState:UIControlStateNormal];
    [qq addTarget:self action:@selector(qq) forControlEvents:UIControlEventTouchUpInside];
    [_footView addSubview:qq];
    UIButton * zan = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/7*3, 10, 20,20)];
     [zan addTarget:self action:@selector(zan) forControlEvents:UIControlEventTouchUpInside];
    [zan setBackgroundImage:[UIImage imageNamed:@"收藏"] forState:UIControlStateNormal];
    [_footView addSubview:zan];
    UIButton * jinRu = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/7*4, 10, 20, 20)];
       [jinRu addTarget:self action:@selector(jinRu) forControlEvents:UIControlEventTouchUpInside];
    [jinRu setBackgroundImage:[UIImage imageNamed:@"购物车"] forState:UIControlStateNormal];
    [_footView addSubview:jinRu];
}
#pragma mark  弹出选择属性页
-(void)shuXing{
//    viewHome = [[UIView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight-20)];
//    viewHome.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
//    
//    [self.view addSubview:viewHome];
    
    _peiZhiView = [[ChanPinPeiZhiView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight) andChanPinmodel:_FL_chanPin];
    _peiZhiView.delegate = self;
    [_peiZhiView queDingGouMaiBen];
    [self.view addSubview:_peiZhiView];
    
    
    
    
}
#pragma mark 弹出产品服务说明页
-(void)baoZheng{
    _viewBaoZheng = [[UIView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight-20)];
    _viewBaoZheng.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
    [self.view addSubview:_viewBaoZheng];
    UIView * contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 200*_kscH, KScreenWidth, KScreenHeight-220*_kscH)];
    contentView.backgroundColor = [UIColor whiteColor];
    [_viewBaoZheng addSubview:contentView];
    UILabel * shuoMing = [[UILabel alloc]initWithFrame:CGRectMake(0, 15, KScreenWidth-30, 20)];
    shuoMing.font = [UIFont systemFontOfSize:14];
    shuoMing.textColor = MaintextColor;
    shuoMing.text = @"服务说明";
    shuoMing.textAlignment = NSTextAlignmentCenter;
    [contentView addSubview:shuoMing];
    UITableView * table = [[UITableView alloc]initWithFrame:CGRectMake(0,shuoMing.bottom+20, KScreenWidth, contentView.height-shuoMing.bottom-55)];
    table.separatorStyle = UITableViewCellSelectionStyleNone;
    
    table.dataSource = self;
    table.delegate = self;
    [table registerClass:[BaoZhengTableViewCell class] forCellReuseIdentifier:@"cell"];
    [contentView addSubview:table];
    UIButton * wanBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, contentView.frame.size.height-35, KScreenWidth,35)];
    [wanBtn setTitle:@"完成" forState:UIControlStateNormal];
    [wanBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    wanBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [wanBtn addTarget:self action:@selector(wanBtn) forControlEvents:UIControlEventTouchUpInside];
    wanBtn.backgroundColor = [UIColor colorWithHue:0.96 saturation:1.00 brightness:1.00 alpha:1.00];
    [contentView addSubview:wanBtn];

}
#pragma mark 服务详情行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}
#pragma mark 服务详情 绘制cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaoZhengTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
   
    cell.dic = _arr[indexPath.row];
    return cell;
}
#pragma mark 点击退出服务详情页
-(void)wanBtn{
    [UIView animateWithDuration:0.5 animations:^{
        CGRect frame = _viewBaoZheng.frame;
        frame.origin.y = KScreenHeight;
        _viewBaoZheng.frame = frame;
    }];
}
#pragma mark 行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  BaoZhengTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.dic = _arr[indexPath.row];

    return  cell.H;
}
#pragma mark 上拉调用的方法
-(void)shangLa{
   
    [_webView loadHTMLString:_FL_chanPin.detail baseURL:[NSURL URLWithString:IP]];

    
}

#pragma mark 网页加载完成时计算高度
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    CGFloat  height = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] floatValue];
    CGRect frame = webView.frame;
    frame.size.height = height;
    webView.frame = frame;
    _scroll.contentSize = CGSizeMake(KScreenWidth, webView.bottom);
    //结束上拉刷新
    [_scroll footerEndRefreshing];
}
#pragma mark  分享
-(void)qq{
}
#pragma mark  点赞
-(void)zan{
     if ([self jianCeLogin]) {
    NSMutableDictionary * requestDic = [[NSMutableDictionary alloc]init];
    [requestDic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [requestDic setObject:_FL_chanPin._id forKey:@"goodsId"];
    [requestDic setObject:@"0" forKey:@"isAttention"];
   [ NetWorking NEWjieKouQingQiu:SC_collect ANDIP:IP And:requestDic anBlock:^(NSDictionary *dic, NSError *error) {
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                   [TCUtils showAlertViewWithTitle:nil message:@"点赞成功" delegate:nil cancel:@"确定" other:nil tag:0];
            }
        }
   }];
     }
}
#pragma mark  进入购物车
-(void)jinRu{
    if ([self jianCeLogin]) {
        GouWuCheMainViewController * gou = [[GouWuCheMainViewController alloc]init];
        gou.timp = 1;
        [self.navigationController pushViewController:gou animated:YES];
    }else{
        GouWuCheMainViewController * gou = [[GouWuCheMainViewController alloc]init];
        gou.a = @"1";
    }
    
}
#pragma mark  加入购物车
-(void)guc{
    if ([self jianCeLogin]) {
    NSMutableDictionary *requestDic= [[NSMutableDictionary alloc]init];
    [requestDic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [requestDic setObject:_FL_chanPin._id forKey:@"goodsId"];
    [requestDic setObject:_gouMaiNum forKey:@"goodsNumber"];
    NSString *shuXingStr = @"";
    
    
    
    for (PeiZhiBtn *peiZhiBtn in _choseAry) {
        shuXingStr = [NSString stringWithFormat:@"%@%@,",shuXingStr,peiZhiBtn.goodsAttrId];
    }
    [requestDic setObject:shuXingStr forKey:@"goodsAttrId"];
    [NetWorking NEWjieKouQingQiu:GWC_addGoods ANDIP:IP And:requestDic anBlock:^(NSDictionary *dic, NSError *error) {
        if (!error) {
            if ([[dic objectForKey:Code]intValue] == 200) {
                
                [[iToast makeText:@"加入购物车成功"]show];
            }
        }
    }];
    }
    
}

#pragma mark  产品详情保证
- (IBAction)baoZheng:(id)sender {
    [UIView animateWithDuration:0.5 animations:^{
        CGRect frame = _viewBaoZheng.frame;
        frame.origin.y = 20;
        _viewBaoZheng.frame = frame;
    }];
}
#pragma mark  评论
- (IBAction)pingLun:(id)sender {
      if ([self jianCeLogin]) {
    PingLunViewController * viewContr = [[PingLunViewController alloc]init];
    [self.navigationController pushViewController:viewContr animated:YES];
      }else{
          DengLuViewController *deng = [[DengLuViewController alloc]init];
          [self.navigationController pushViewController:deng animated:YES];
      }
}
#pragma mark  详情属性选择
- (IBAction)xuanZe:(id)sender {
    [UIView animateWithDuration:0.5 animations:^{
        _peiZhiView.yv = 0;
    }];
 }
#pragma mark 关闭详情页属性
-(void)guanBi{
    [UIView animateWithDuration:0.5 animations:^{
        _peiZhiView.yv = KScreenHeight;
    }];
}

#pragma mark peiZhiViewDelegate
-(void)quDingBtnWiht:(NSArray *)choseBtnAry and:(NSString *)count{
    
    [UIView animateWithDuration:0.5 animations:^{
        _peiZhiView.yv = KScreenHeight;
    }];

    NSString *yiXuanShuXing = @"已选 ";
    
    for (PeiZhiBtn *peiZhiBtn in choseBtnAry) {
        yiXuanShuXing = [NSString stringWithFormat:@"%@/%@",yiXuanShuXing,peiZhiBtn.attrValue];
    }
    _guiGeLabel.text = yiXuanShuXing;
    
    
    _choseAry = choseBtnAry ;
    _gouMaiNum = count;
    
}
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{

}

@end
